package com.hare.harelearn.DataStructure.AlgorithmExercises.十大排序;

import java.util.Arrays;

public class BubbleSortLearn {
    public static void main(String[] args) {
        int array[] = new int[]{5,78,45,3,44,33,14};
        bubbleSort(array);
        System.out.println(Arrays.toString(array));
    }


    /**
     * 冒泡排序
     *
     * @param param 未排序数组参数
     * @return
     */
    public static void bubbleSort(int[] param) {
        int length = param.length;
        int temp = 0;
        for (int i = 0; i < length-1; i++) {
            for (int j = 0; j < length - 1 -i; j++) {
                if (param[j] > param[j+1]) {
                    temp = param[j];
                    param[j] = param[j+1];
                    param[j+1] = temp;
                }
            }
        }
    }
}
